# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=dbus

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.4
pkgrel=1
arch=('any')
pkgdesc="Freedesktop.org message bus system (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2" "${MINGW_PACKAGE_PREFIX}-expat")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-python2" "xmlto")
options=('strip' 'staticlibs')
license=("BSD")
url="http://www.freedesktop.org/wiki/Software/dbus"
source=("http://dbus.freedesktop.org/releases/dbus/${_realname}-${pkgver}.tar.gz"{,.asc})
md5sums=('4717cb8ab5b80978fcadf2b4f2f72e1b'
         'SKIP')

prepare() {
  cd "${srcdir}"/dbus-${pkgver}
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  CFLAGS+=" -mms-bitfields"
  CXXFLAGS+=" -mms-bitfields"

  ../dbus-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-xml-docs \
    --disable-systemd \
    --disable-tests \
    --disable-Werror \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  make DESTDIR=$pkgdir install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  #rm -rf "${pkgdir}${MINGW_PREFIX}"/share/man
  #rm -rf "${pkgdir}${MINGW_PREFIX}"/{etc,var,libexec,share}
}
